package com.example.seckill.utils;

import org.thymeleaf.util.StringUtils;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * @Author: Jason
 * @ClassName: ValidatorUtil
 * @Description: 手机号码校验
 * @Package：com.example.seckill.utils
 * @Project：seckill
 * @name：validatorUtil
 * @Filename：validatorUtil
 **/

public class ValidatorUtil {

    //正则表达式
    private static final Pattern mobile_pattern = Pattern.compile("[1]([3-9])[0-9]{9}$");

    public static boolean isMobile(String mobile){
        if (StringUtils.isEmpty(mobile)){
            return false;
        }
        Matcher matcher = mobile_pattern.matcher(mobile);
        return matcher.matches();
    }

//    public static void main(String[] args) {
//        System.out.println(isMobile("18012345678"));
//    }

}
